<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>订单详情</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript" src="${ctxStatic}/common/jquery.jqprint-0.3.js"></script>
    <script>
        $(document).ready(function() {
            $("#btnSubmit").click(function(){
                var seas=$("#oversea").val();
               // alert(seas==1);
                if(seas==1){
                    var logisticsN=$("#logisticsN").val();
                    alert(logisticsN!=null&&logisticsN!='');
                    if(logisticsN!=null&&logisticsN!=''){
                     //   alert('yes');
                       $("#inputForm").submit();
                    }else{
                      //  alert("ok");
                        document.getElementById("nu").innerHTML="物流单号不能为空！";
                    }

                }else{
                    $("#inputForm").submit();
                    //alert('no');
                }
            });
            //计算 商品小计金额
            $("input[name='orderProPrice']").each(function(){
                var price = $(this).val();
                var quantity = $(this).next("input").val();
                var xiaoji = parseFloat(price).toFixed(2) * parseInt(quantity);
                $(this).parent().html(xiaoji.toFixed(2));
            })
        });
        function isNot(){
            var logisticsN=$("#logisticsN").val();
            if(logisticsN!=null&&logisticsN!=''){
                document.getElementById("nu").innerHTML="*";
            }
        }
    </script>
</head>

<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/sys/orderProduct/">订单明细</a></li>
</ul>
<br/>
<form:form id="inputForm"  action="${ctx}/sys/orderProduct/editOrderProductState" method="post" class="form-horizontal">
    <input type="hidden" name="id" value="${tbOrder.id}"/>
    <input type="hidden" name="state" value="3"/>
    <input type="hidden" id="oversea" name="overse" value="${oversea}">
    <input type="hidden" id="showUrl" name="showUrl" value="${tbOrder.showUrl}">
    <!-- 用此字段存储海外购店铺下的海外订单的id -->
    <input type="hidden" name="shopId" value="${shopProId}">
    <div id="printDiv">
        <b><div id="orderNoDiv" style="font-size: 16px;">
            订单号:
        </div></b>
        <table id="contentTable" class="table table-striped table-bordered table-condensed">
            <thead>
            <tr>
                <th>订单类型</th>
                <th>商品名称</th>
                <th>商品属性</th>
                <th>商品类型</th>
                <th>商品价格</th>
                <th>商品数量</th>
                <th>小计</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${tbOrderProductList}" var="tbOrderProduct">
                <tr>
                    <td>
                        <c:choose>
                            <c:when test="${flag==1}">
                                生活预定
                            </c:when>
                            <c:when test="${flag==0}">
                                便利生活
                            </c:when>
                            <c:when test="${flag==2}">
                                海外代购
                            </c:when>
                        </c:choose>
                    </td>
                    <td>${tbOrderProduct.productName}
                        <input type="hidden" class="orderNoName" value="${tbOrder.orderNo}"/>
                        <input type="hidden" class="contactName" value="${tbOrder.contactName}"/>
                        <input type="hidden" class="contactMobile" value="${tbOrder.contactMobile}"/>
                        <input type="hidden" class="payTime" value="${tbOrder.payTime}"/>
                        <c:if test="${tbOrder.payState eq '0'}">
                            <input type="hidden" class="payState" value="未付款"/>
                        </c:if>
                        <c:if test="${tbOrder.payState eq '1'}">
                            <input type="hidden" class="payState" value="已付款"/>
                        </c:if>
                        <c:if test="${tbOrder.payId eq '1'}">
                            <input type="hidden" class="payId" value="物业钱包"/>
                        </c:if>
                        <c:if test="${tbOrder.payId eq '2'}">
                            <input type="hidden" class="payId" value="麻雀钱包"/>
                        </c:if>
                        <c:if test="${tbOrder.payId eq '3'}">
                            <input type="hidden" class="payId" value="微信"/>
                        </c:if>
                        <c:if test="${tbOrder.payId eq '5'}">
                            <input type="hidden" class="payId" value="现金"/>
                        </c:if>
                        <c:if test="${tbOrder.payId eq '6'}">
                            <input type="hidden" class="payId" value="银行卡"/>
                        </c:if>
                    </td>
                    <td>${tbOrderProduct.attr}</td>
                    <td>${tbOrderProduct.categoryName}</td>

                    <td>${tbOrderProduct.price}</td>
                    <td>${tbOrderProduct.quantity}</td>
                    <td name="litleTotal"></td>
                    <!--  <td><fmt:formatDate value="${tbOrder.payTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td> -->
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <table class="table table-striped table-condensed">
            <tr>
                <td id="contactName">联系人:</td>
                <td id="contactMobile">联系电话:</td>
                <td id="payId">支付方式:</td>
                <td id="payTime">支付时间:</td>
                <td id="payState">支付状态:</td>
            </tr>
        </table>
        <h3 align="right">订单总额：  ${tbOrder.orderAmount}</h3>
    </div>

    <c:choose>
        <c:when test="${oversea==1}">
            <div class="control-group">
                <label class="control-label">物流公司编号:</label>
                <div class="controls">
                    <select name="logisticsCode" class="input-medium">
                        <option <c:if test="${reserveTbOrder.logisticsCode eq SF}"> selected </c:if> value="SF">顺丰快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='AJ'}"> selected </c:if> value="AJ">安捷快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ANE'}"> selected </c:if> value="ANE">安能物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='AXD'}">selected</c:if>  value="AXD">安信达快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='BQXHM'}">selected</c:if>  value="BQXHM">北青小红帽</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='BFDF'}">selected</c:if>  value="BFDF">百福东方</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='BTWL'}">selected</c:if>  value="BTWL">百世快运</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SF'}">selected</c:if>  value="CCES">CCES快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='CCES'}">selected</c:if>  value="CITY100">城市100</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='COE'}">selected</c:if>  value="COE">COE东方快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='CSCY'}">selected</c:if>  value="CSCY">长沙创一</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SF'}">selected</c:if>  value="CDSTKY">成都善途速运</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='CDSTKY'}">selected</c:if>  value="DBL">德邦</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='DSWL'}">selected</c:if>  value="DSWL">D速物流</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='DTWL'}">selected</c:if> value="DTWL">大田物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='EMS'}">selected</c:if>  value="EMS">EMS</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='FAST'}">selected</c:if>  value="FAST">快捷速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='FEDEX'}">selected</c:if>  value="FEDEX">FEDEX联邦(国内件）</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='FEDEX_GJ'}">selected</c:if>  value="FEDEX_GJ">FEDEX联邦(国际件）</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='FKD'}">selected</c:if>  value="FKD">飞康达</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='GDEMS'}">selected</c:if> value="GDEMS">广东邮政</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='SF'}">selected</c:if> value="GSD">共速达</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='GSD'}">selected</c:if>  value="GTO">国通快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='GTSD'}">selected</c:if>  value="GTSD">高铁速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HFWL'}">selected</c:if>  value="HFWL">汇丰物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HHTT'}">selected</c:if>  value="HHTT">天天快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HLWL'}">selected</c:if>  value="HLWL">恒路物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HOAU'}">selected</c:if>  value="HOAU">天地华宇</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='hq568'}">selected</c:if>  value="hq568">华强物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HTKY'}">selected</c:if>  value="HTKY">百世快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HXLWL'}">selected</c:if>  value="HXLWL">华夏龙物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HYLSD'}">selected</c:if>  value="HYLSD">好来运快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JGSD'}">selected</c:if>  value="JGSD">京广速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JIUYE'}">selected</c:if>  value="JIUYE">九曳供应链</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JJKY'}">selected</c:if>  value="JJKY">佳吉快运</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JLDT'}">selected</c:if>  value="JLDT">嘉里物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JTKD'}">selected</c:if>  value="JTKD">捷特快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JXD'}">selected</c:if>  value="JXD">急先达</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JYKD'}">selected</c:if>  value="JYKD">晋越快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JYM'}">selected</c:if>  value="JYM">加运美</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='JYWL'}">selected</c:if>  value="JYWL">佳怡物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='KYWL'}">selected</c:if>  value="KYWL">跨越物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='LB'}">selected</c:if>  value="LB">龙邦快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='LHT'}">selected</c:if>  value="LHT">联昊通速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='MHKD'}">selected</c:if>  value="MHKD">民航快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='MLWL'}">selected</c:if>  value="MLWL">明亮物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='NEDA'}">selected</c:if>  value="NEDA">能达速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='PADTF'}">selected</c:if>  value="PADTF">平安达腾飞快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='QCKD'}">selected</c:if>  value="QCKD">全晨快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='QFKD'}">selected</c:if> value="QFKD">全峰快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='QRT'}">selected</c:if>  value="QRT">全日通快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='RFD'}">selected</c:if> value="RFD">如风达</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SAD'}">selected</c:if>  value="SAD">赛澳递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='SAWL'}">selected</c:if> value="SAWL">圣安物流</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='SBWL'}">selected</c:if> value="SBWL">盛邦物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SDWL'}">selected</c:if>  value="SDWL">上大物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SFWL'}">selected</c:if>  value="SFWL">盛丰物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SHWL'}">selected</c:if>  value="SHWL">盛辉物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ST'}">selected</c:if>  value="ST">速通物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='STO'}">selected</c:if>  value="STO">申通快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='STWL'}">selected</c:if> value="STWL">速腾快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='SURE'}">selected</c:if> value="SURE">速尔快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='TSSTO'}">selected</c:if> value="TSSTO">唐山申通</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='UAPEX'}">selected</c:if>  value="UAPEX">全一快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='UC'}">selected</c:if>  value="UC">优速快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='WJWL'}">selected</c:if> value="WJWL">万家物流</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='WXWL'}">selected</c:if> value="WXWL">万象物流</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='XBWL'}">selected</c:if> value="XBWL">新邦物流</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='XFEX'}">selected</c:if> value="XFEX">信丰快递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='XYT'}">selected</c:if> value="XYT">希优特</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='XJ'}">selected</c:if> value="XJ">新杰物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YADEX'}">selected</c:if>  value="YADEX">源安达快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YCWL'}">selected</c:if>  value="YCWL">远成物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YD'}">selected</c:if>  value="YD">韵达快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YDH'}">selected</c:if>  value="YDH">义达国际物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YFEX'}">selected</c:if>  value="YFEX">越丰物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YFHEX'}">selected</c:if>  value="YFHEX">原飞航物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YFSD'}">selected</c:if>  value="YFSD">亚风快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YTKD'}">selected</c:if>  value="YTKD">运通快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YTO'}">selected</c:if>  value="YTO">圆通速递</option>
                        <option  <c:if test="${reserveTbOrder.logisticsCode=='YXKD'}">selected</c:if> value="YXKD">亿翔快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='YZPY'}">selected</c:if>  value="YZPY">邮政平邮/小包</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZENY'}">selected</c:if>  value="ZENY">增益快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZHQKD'}">selected</c:if>  value="ZHQKD">汇强快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZJS'}">selected</c:if>  value="ZJS">宅急送</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZTE'}">selected</c:if>  value="ZTE">众通快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZTKY'}">selected</c:if>  value="ZTKY">中铁快运</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZTO'}">selected</c:if>  value="ZTO">中通速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZTWL'}">selected</c:if>  value="ZTWL">中铁物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='ZYWL'}">selected</c:if>  value="ZYWL">中邮物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='AMAZON'}">selected</c:if>  value="AMAZON">亚马逊物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='SUBIDA'}">selected</c:if>  value="SUBIDA">速必达物流</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='RFEX'}">selected</c:if>  value="RFEX">瑞丰速递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='QUICK'}">selected</c:if>  value="QUICK">快客快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='CJKD'}">selected</c:if>  value="CJKD">城际快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='CNPEX'}">selected</c:if>  value="CNPEX">CNPEX中邮快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HOTSCM'}">selected</c:if>  value="HOTSCM">鸿桥供应链</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='HPTEX'}">selected</c:if>  value="HPTEX">海派通物流公司</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='AYCA'}">selected</c:if>  value="AYCA">澳邮专线</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='PANEX'}">selected</c:if>  value="PANEX">泛捷快递</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='PCA'}">selected</c:if>  value="PCA">PCA Express</option>
                        <option <c:if test="${reserveTbOrder.logisticsCode=='UEQ'}">selected</c:if>  value="UEQ">UEQ Express</option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">物流单号:</label>
                <div class="controls">
                    <input name="logisticsNumber" id="logisticsN" type="text" htmlEscape="false" onblur="isNot()" value="${reserveTbOrder.logisticsNumber}" maxlength="50" class="required"/>
                    <span class="help-inline"><font color="red" id="nu">*</font> </span>
                </div>
            </div>
        </c:when>
        <c:otherwise>
            <input type="hidden" id="logisticsNumber" name="logisticsNumber" value="00000">
        </c:otherwise>
    </c:choose>
    <div align="right" class="form-actions">

        <c:choose>
            <c:when test="${tbOrder.orderState eq '1'}">
                <input id="btnSubmit" class="btn btn-primary" type="button" value="确认发货"/>
            </c:when>
            <c:when test="${tbOrder.orderState eq '2'}">
                <input id="btnSubmit" class="btn btn-primary" type="button" value="确认发货"/>
            </c:when>
        </c:choose>
        <input type="button" class="btn btn-primary" onclick="myprint()" value="打印"/>
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>

</form:form>
<script language="javascript">
    $(function(){
        $(".orderNoName").each(function(){
            $("#orderNoDiv").append(($(this).val()));
            return false;
        })
        $(".contactName").each(function(){
            $("#contactName").append(($(this).val()));
            return false;
        })
        $(".contactMobile").each(function(){
            $("#contactMobile").append(($(this).val()));
            return false;
        })
        $(".payState").each(function(){
            $("#payState").append(($(this).val()));
            return false;
        })
        $(".payId").each(function(){
            $("#payId").append(($(this).val()));
            return false;
        })
        $(".payTime").each(function(){
            $("#payTime").append(new Date($(this).val()).format("yyyy-MM-dd hh:mm:ss"));
            return false;
        })
        $("td[name=litleTotal]").each(function(){
            var quantity = parseInt($(this).prev("td").html());
            var price = parseFloat($(this).prev("td").prev("td").html());
            $(this).html(parseFloat(quantity*price).toFixed(2));
//            return false;
        })
    });
    function  myprint(){
        $("#printDiv").jqprint({
            debug: false, //如果是true则可以显示iframe查看效果（iframe默认高和宽都很小，可以再源码中调大），默认是false
            importCSS: true, //true表示引进原来的页面的css，默认是true。（如果是true，先会找$("link[media=print]")，若没有会去找$("link")中的css文件）
            printContainer: true, //表示如果原来选择的对象必须被纳入打印（注意：设置为false可能会打破你的CSS规则）。
            operaSupport: true//表示如果插件也必须支持歌opera浏览器，在这种情况下，它提供了建立一个临时的打印选项卡。默认是true
        });
    }
    /**
     * 时间对象的格式化;
     */
    Date.prototype.format = function(format) {
        /*
         * eg:format="yyyy-MM-dd hh:mm:ss";
         */
        var o = {
            "M+" : this.getMonth() + 1, // month
            "d+" : this.getDate(), // day
            "h+" : this.getHours(), // hour
            "m+" : this.getMinutes(), // minute
            "s+" : this.getSeconds(), // second
            "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
            "S" : this.getMilliseconds()
            // millisecond
        }

        if (/(y+)/.test(format)) {
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4
                    - RegExp.$1.length));
        }

        for (var k in o) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length == 1
                        ? o[k]
                        : ("00" + o[k]).substr(("" + o[k]).length));
            }
        }
        return format;
    }
</script>
</body>
</html>
